//
//  RBHttpNetworkHelper.h
//  RMMaterialRed
//
//  Created by XBWH on 2024/3/6.
//

#import <UIKit/UIKit.h>
@class AFHTTPSessionManager;
NS_ASSUME_NONNULL_BEGIN

typedef NS_ENUM(NSUInteger, RBNetworkStatusType) {
    RBNetworkStatusUnknown,
    RBNetworkStatusNotReachable,
    RBNetworkStatusReachableViaWWAN,
    RBNetworkStatusReachableViaWiFi
};
typedef NS_ENUM(NSUInteger, RBRequestSerializer) {
    RBRequestSerializerJSON,
    RBRequestSerializerHTTP,
};
typedef NS_ENUM(NSUInteger, RBResponseSerializer) {
    RBResponseSerializerJSON,
    RBResponseSerializerHTTP,
};
typedef void(^RBHttpRequestSuccess)(id responseObject);
typedef void(^RBHttpRequestFailed)(NSError *error);
typedef void(^RBHttRBrogress)(NSProgress *progress);
typedef void(^RBNetworkStatus)(RBNetworkStatusType status);

@interface RBHttpNetworkHelper : NSObject

+ (void)setAFHTTPSessionManagerProperty:(void(^)(AFHTTPSessionManager *sessionManager))sessionManager;
+ (void)setRequestSerializer:(RBRequestSerializer)requestSerializer;
+ (void)setResponseSerializer:(RBResponseSerializer)responseSerializer;
+ (void)setRequestTimeoutInterval:(NSTimeInterval)time;
+ (void)setValue:(NSString *)value forHTTPHeaderField:(NSString *)field;
+ (void)openNetworkActivityIndicator:(BOOL)open;
+ (void)setSecurityPolicyWithCerPath:(NSString *)cerPath validatesDomainName:(BOOL)validatesDomainName;

///GET请求
+ (NSURLSessionTask *)GET:(NSString *)URL
                        parameters:(id)parameters
                           success:(RBHttpRequestSuccess)success
                           failure:(RBHttpRequestFailed)failure;

///POST请求
+ (NSURLSessionTask *)POST:(NSString *)URL
                         parameters:(id)parameters
                            success:(RBHttpRequestSuccess)success
                            failure:(RBHttpRequestFailed)failure;
@end

NS_ASSUME_NONNULL_END
